/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.be;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.cip.esymons.general.be.DireccionPersona;

/**
 *
 * @author FreddyHIQ
 */
@Entity
@Table(name = "tra_dir_recep")
@NamedQueries({@NamedQuery(name = "DirRecep.findAll", query = "SELECT d FROM DirRecep d"), @NamedQuery(name = "DirRecep.findByDreTransac", query = "SELECT d FROM DirRecep d WHERE d.dreTransac = :dreTransac")})
public class DirRecep implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "dre_transac")
    private Long dreTransac;
    @JoinColumn(name = "dre_transac", referencedColumnName = "tra_codigo", insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Transaccion transaccion;
    @JoinColumn(name = "dre_direccion", referencedColumnName = "dpe_codigo")
    @ManyToOne(fetch = FetchType.LAZY)
    private DireccionPersona dreDireccion;

    public DirRecep() {
    }

    public DirRecep(Long dreTransac) {
        this.dreTransac = dreTransac;
    }

    public DirRecep(Transaccion transaccion, DireccionPersona dreDireccion) {
        this.dreTransac = transaccion.getTraCodigo();
        this.dreDireccion = dreDireccion;
    }

    public Long getDreTransac() {
        return dreTransac;
    }

    public void setDreTransac(Long dreTransac) {
        this.dreTransac = dreTransac;
    }

    public Transaccion getTransaccion() {
        return transaccion;
    }

    public void setTransaccion(Transaccion transaccion) {
        this.transaccion = transaccion;
    }

    public DireccionPersona getDreDireccion() {
        return dreDireccion;
    }

    public void setDreDireccion(DireccionPersona dreDireccion) {
        this.dreDireccion = dreDireccion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dreTransac != null ? dreTransac.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DirRecep)) {
            return false;
        }
        DirRecep other = (DirRecep) object;
        if ((this.dreTransac == null && other.dreTransac != null) || (this.dreTransac != null && !this.dreTransac.equals(other.dreTransac))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.tramite.be.DirRecep[dreTransac=" + dreTransac + "]";
    }

}
